package org.xiaojl.modules.sys.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.xiaojl.modules.sys.entity.SysUser;
import org.xiaojl.modules.sys.entity.SysUserRole;
import org.xiaojl.modules.sys.mapper.SysUserMapper;
import org.xiaojl.modules.sys.mapper.SysUserRoleMapper;
import org.xiaojl.modules.sys.service.SysUserService;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;

/**
 * <p>
 * 系统用户 服务实现类
 * </p>
 *
 * @author xiaojl
 * @since 2017-08-18
 */
@Service
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements SysUserService {
	@Autowired
	private SysUserMapper sysUserMapper;
	@Autowired
	private SysUserRoleMapper sysUserRoleMapper;
	
	@Override
	public List<SysUser> selectAllByRoleId(Long roleId) {
		return sysUserMapper.selectAllByRoleId(roleId);
	}

	@Override
	public void deleteWithCascade(Long id) {
		//1 删除用户角色信息
		sysUserRoleMapper.delete(new EntityWrapper<SysUserRole>().eq("userId",id));
		//2 删除用户信息
		sysUserMapper.deleteById(id);
	}

	
}
